Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Korad KKG305P #219

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

IvanBayan
Copy link

Support for KKG305P with new quirk.
korad_kaxxxxp_send_cmd() changed in a way to support new line termination.
STATUS parsed according to Korad "documentation".
New flags in device structure to support status of remote sensing status and external control interface status.

Ivan Churkin added 2 commits May 31, 2023 00:21
Support for KKG305P with new quirk.
korad_kaxxxxp_send_cmd() changed in a way to support adding new line
termination.
STATUS parsed according to Korad "documentation".
New flags in device structure to support status of remote sensing status
and external control interface status.
@abraxa
Copy link
Member

abraxa commented Sep 27, 2023

Hi, thanks for your contribution! Would you be so kind and rebase your branch on top of current git head to solve the conflicts?

@IvanBayan
Copy link
Author

I will try and let you know.

Copy link
Contributor

@fenugrec fenugrec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note I am neither a main dev or maintainer of sigrok. Just a 'concerned citizen')

I don't see major problems, but I wonder about the choice of changing every call to korad_kaxxxxp_send_cmd() with the extra arg.
I think I would've implemented a new korad_kkg_send_cmd() with the newline fixes (but no additional argument); change the korad_kaxxxxp_send_cmd() call sites to a instead call a *function pointer, and set that function pointer once at device init according to device type. Then after writing that I would then start doubting on whether it was a even a good idea.

Hope we get some input from others about this

{
int ret;
uint32_t cmd_len;
char *_cmd;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a fan of leading underscores for var names

}

sr_dbg("Sending '%s'.", _cmd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest moving this before you append the newline, so the debug message doesn't end up with sometimes a stray \n ?

}

sr_dbg("Sending '%s'.", _cmd);
if ((ret = serial_write_blocking(serial, _cmd, cmd_len, 0)) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the assignment outside the conditional

@@ -323,16 +341,35 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial,
prev_status = devc->cc_mode[0];
devc->cc_mode[0] = !(status_byte & (1 << 0));
devc->cc_mode_1_changed = devc->cc_mode[0] != prev_status;

if( devc->model->quirks & KORAD_QUIRK_KKG_FAMILY) {
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing indent inside block, bad whitespace in if(


/*
* Tracking:
* status_byte & ((1 << 2) | (1 << 3))
* 00 independent 01 series 11 parallel
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated whitespace

(status_byte & (1 << 5)) ? "enabled" : "disabled",
(status_byte & (1 << 7)) ? "enabled" : "disabled",
(status_byte & (1 << 4)) ? "beeping" : "silent");
if( devc->model->quirks & KORAD_QUIRK_KKG_FAMILY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another if(


gboolean cc_mode_1_changed; /**< CC mode of channel 1 has changed. */
gboolean cc_mode_2_changed; /**< CC mode of channel 2 has changed. */
gboolean output_enabled_changed; /**< Output enabled state has changed. */
gboolean ocp_enabled_changed; /**< OCP enabled state has changed. */
gboolean ovp_enabled_changed; /**< OVP enabled state has changed. */
gboolean rmt_comp_changed; /**< Is remote compensation enabled. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong copypasted comment here and below, enabled-> changed

@fenugrec
Copy link
Contributor

Also forgot to mention, one of these commits [Fix un-conditional double read](https://github.com/sigrokproject/libsigrok/pull/219/commits/d4726c18019c5b84d1b7458e0a3bcfbebbf5f592) will need a better commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants